﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace ProtoGame.GameLib.Entities
{
    public abstract class GraphicEntity : Entity
    {
        public Color ColorEffects { get; set; }
        public Vector2 Scale { get; set; }
        public Vector2 Origin { get; set; }
        public float Rotation { get; set; }

        public SpriteEffects Flip { get; set; }

        /// <summary>
        /// The sorting depth of the sprite, between 0 (front) and 1 (back). You must specify either
        /// SpriteSortMode.FrontToBack or SpriteSortMode.BackToFront for this parameter to affect sprite drawing.
        /// </summary>
        public virtual float LayerDepth { get; set; }

        public GraphicEntity()
        {
            Visible = true;
            Origin = Vector2.Zero;
            Scale = Vector2.One;
            Rotation = 0;
            Flip = SpriteEffects.None;
            LayerDepth = 0;
            ColorEffects = Color.White;
        }

        public virtual byte Fade
        {
            get { return ColorEffects.A; }
            set
            {
                Color newcolor = ColorEffects;
                newcolor.A = value;
                ColorEffects = newcolor;
            }
        }

        //byte _beforeInvisible = byte.MaxValue;
        public bool Visible
        {
            get;
            set;
            /*get { return Fade != 0; }
            set
            {
                if (!value)
                {
                    _beforeInvisible = Fade;
                    Fade = byte.MinValue;
                }
                else if (Visible)
                    Fade = _beforeInvisible;
            }*/
        }

        protected override void LifetimeElapsed()
        {
            Visible = false;
            base.LifetimeElapsed();
        }

        public abstract void Draw(SpriteBatch spriteBatch);
    }
}
